/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ws.converter;

import entidade.persistencia.TipoUsuario;
import java.net.URI;
import java.util.Collection;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlAttribute;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author victorinox
 */

@XmlRootElement(name = "tipoUsuarioes")
public class TipoUsuarioesConverter {
    private List<TipoUsuario> entities;
    private List<TipoUsuarioConverter> items;
    private URI uri;
    private int expandLevel;
  
    /** Creates a new instance of TipoUsuarioesConverter */
    public TipoUsuarioesConverter() {
    }

    /**
     * Creates a new instance of TipoUsuarioesConverter.
     *
     * @param entities associated entities
     * @param uri associated uri
     * @param expandLevel indicates the number of levels the entity graph should be expanded
     */
    public TipoUsuarioesConverter(List<TipoUsuario> entities, URI uri, int expandLevel) {
        this.entities = entities;
        this.uri = uri;
        this.expandLevel = expandLevel;
        getTipoUsuario();
    }

    /**
     * Returns a collection of TipoUsuarioConverter.
     *
     * @return a collection of TipoUsuarioConverter
     */
    @XmlElement
    public List<TipoUsuarioConverter> getTipoUsuario() {
        if (items == null) {
            items = new ArrayList<TipoUsuarioConverter>();
        }
        if (entities != null) {
            for (TipoUsuario entity : entities) {
                items.add(new TipoUsuarioConverter(entity, uri, expandLevel, true));
            }
        }
        return items;
    }

    /**
     * Sets a collection of TipoUsuarioConverter.
     *
     * @param a collection of TipoUsuarioConverter to set
     */
    public void setTipoUsuario(List<TipoUsuarioConverter> items) {
        this.items = items;
    }

    /**
     * Returns the URI associated with this converter.
     *
     * @return the uri
     */
    @XmlAttribute
    public URI getUri() {
        return uri;
    }

    /**
     * Returns a collection TipoUsuario entities.
     *
     * @return a collection of TipoUsuario entities
     */
    @XmlTransient
    public List<TipoUsuario> getEntities() {
        entities = new ArrayList<TipoUsuario>();
        if (items != null) {
            for (TipoUsuarioConverter item : items) {
                entities.add(item.getEntity());
            }
        }
        return entities;
    }
}
